package cn.edu.zafu.bigdata.cccnnn.workthree;

class element{
    public static int getElement(int[] arr, int index){
        if (index> arr.length){
            throw new ArrayIndexOutOfBoundsException("out of arr‘s length "+"Index: " + index + ", Size: " + arr.length);
        }
        else {
            return arr[index];
        }
    }
}


public class TestgetElement {
    public static void main(String[] args){
        int[] myArray = {10,20,30,40,90};
        try {

            int a = element.getElement(myArray,7);
            System.out.println("find:"+a);
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println(e.getMessage());
        }
    }
}
